home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Graphics Programming (2nd Edition)
/
Visual Basic Graphics Programming 2nd Edition.iso
/
Src
/
Ch17
/
Arctan.bas
< prev
next >
Wrap
BASIC Source File
|
1999-06-06
|
470b
|
23 lines
Attribute VB_Name = "Arctan"
Option Explicit
' Return the arctan of dy/dx.
Public Function ATan2(ByVal dy As Single, ByVal dx As Single) As Single
Const PI = 3.14159265
Dim theta As Single
If Abs(dx) < 0.01 Then
If dy < 0 Then
theta = -PI / 2
Else
theta = PI / 2
End If
Else
theta = Atn(dy / dx)
If dx < 0 Then theta = PI + theta
End If
ATan2 = theta
End Function